package threads.multirun;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.Callable;

public class Task implements Callable<String> {

	private Long number;

	public Task(Long number) {
		this.number = number;
	}

	@Override
	public String call() throws Exception {
		System.out.println("Thread " + number + " started at " + getCurrentTime());

		try {
			Thread.sleep(number * 100L);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}

		System.out.println("Thread " + number + " finished at " + getCurrentTime());
		return "ok";
	}

	
	
	private String getCurrentTime() {
		DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSS");
        
		return dateFormat.format(new Date());
        
	}
	
}
